<?php
/**
 * 店铺管理模块
 *
 * @author river_he@eueang.com
 */
final class Kit_Model_Shop extends Kit_Model_Abstract{
	
	/**
	 * 获取店铺列表
	 * 
	 * @param array|string $where
	 * @param string $order
	 * @param int $page
	 * @param int $psize
	 * @return array
	 */
	public function getItems($where, $order='', $page=1, $psize=10){
		return $this->getShopDao()->getItems($where, $order, $page, $psize);
	}
	
	/**
	 * 获取店铺使用道具列表
	 * 
	 * @param array|string $where
	 * @param string $order
	 * @param int $page
	 * @param int $psize
	 * @return array
	 */
	public function getProps($shopId){
		$return = array();
		if(0 < $shopId){
			$where = array('nShopId='.$shopId);
			array_push($where, 'nStatus=2');
			//@todo 道具过期时间未做处理（脚本来处理？maybe）
			$return = $this->getShopPropDao()->getItems($where, 'id ASC', 1, 20);
		}
		return $retrun;
	}
	
	/**
	 * 获取店铺装饰品列表
	 * 
	 * @param array|string $where
	 * @param string $order
	 * @param int $page
	 * @param int $psize
	 * @return array
	 */
	public function getDecos($shopId){
		$return = array();
		if($shopId){
			$where = array('nShopId='.$shopId);
			array_push($where, 'nStatus=2');
			//@todo 材料过期时间未做处理
			$data = $this->getShopDecoDao()->getItems($where, 'nPosit, nPz ASC', 1, 20);
			$return = $data;
		}
		return $return;
	}
	
	/**
	 * 获取店铺储藏室物品
	 * 
	 * @param int $shopId
	 * @param int $type
	 * @param int $page
	 * @param int $psize
	 * @return array
	 */
	public function getStocks($shopId, $type, $page=1, $psize=10){
		$items = array();
		if(0 < $shopId){
			if($type == 1){
				$items = $this->getShopMaterialDao()->getItems('nShopId='.$shopId, 'nUseTime ASC', $page, $psize);
				if($items){
					$materDao = new Kit_Dao_Material();
					foreach($items as $item){
						//@todo jixu
						print_r($item);
					}
				}
			}elseif($type == 2){
				$items = $this->getPropDao()->getItems('nShopId='.$shopId, 'nUseTime ASC', $page, $psize);
			}
		}
		return $items;
	}
	
	/**
	 * 获取单个店铺
	 * 
	 * @param array|string $where
	 * @return array
	 */
	public function getItem($where, $sort='id DESC'){
		return $this->getShopDao()->getItem($where, $sort);
	}
	
	/**
	 * 获取店铺对应的统计表
	 * 
	 * @param array|string $where
	 * @return array
	 */
	public function getStat($where){
		return $this->getShopStatDao()->getItem($where, '');
	}
}
//end